//
//  CycleScrollView.h
//  116114
//
//  Created by 潘超 on 13-7-23.
//  Copyright (c) 2013年 Raiyi. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SliderPageControl.h"
enum{
    PageControlTypeDefault,
    PageControlTypeSlider,
};typedef int PageControlType;

@protocol CycleScrollViewDelegate;
@protocol CycleScrollViewDatasource;

@interface CycleScrollView : UIView<UIScrollViewDelegate,SliderPageControlDelegate>
{
    UIScrollView *_scrollView;
    UIPageControl *_pageControl;
    int pageControlType;
    __weak id<CycleScrollViewDelegate> _delegate;
    __weak id<CycleScrollViewDatasource> _datasource;
    
    NSInteger _totalPages;
    NSInteger _curPage;
    
    NSMutableArray *_curViews;
    NSTimer *_timer;
}

@property (nonatomic,readonly) UIScrollView *scrollView;
@property (nonatomic,readonly) UIPageControl *pageControl;
@property (nonatomic) NSInteger currentPage;
@property (nonatomic,weak,setter = setDataource:) id<CycleScrollViewDatasource> datasource;
@property (nonatomic,weak,setter = setDelegate:) id<CycleScrollViewDelegate> delegate;
@property (nonatomic,strong)   SliderPageControl *sliderPageControl;

- (id)initWithFrame:(CGRect)frame withPageControlStyle:(int)type withPageControlFrame:(CGRect)pFrame addSubViewToView:(UIView *) sView;
- (void)reloadData;
-(void) setViewFrame:(CGRect)frame;
- (void)setViewContent:(UIView *)view atIndex:(NSInteger)index;
-(void) setPageControlStyle:(int)type andFrame:(CGRect)frame;
-(void) startAutoScroll:(NSTimeInterval) time;
-(void) stopAutoScroll;
-(BOOL) isAutoScroll;

@end

@protocol CycleScrollViewDelegate <NSObject>

@optional
- (void)didClickPage:(CycleScrollView *)csView atIndex:(NSInteger)index;

@end

@protocol CycleScrollViewDatasource <NSObject>

@required
- (NSInteger)numberOfPagesAt:(CycleScrollView *) csView;
- (UIView *) cycleScrollView:(CycleScrollView *) csView pageAtIndex:(NSInteger)index;

@end
